var app = getApp();
var $ = app.globalData;
Page({
	data: {

	},
	onLoad: function(options) {
		var that = this
		// 获取店铺id
		that.setData({
			myshopid:$.myshopid
		})
		// 获取用户信息&&判断有没有登录&&更新用户信息
		wx.getStorage({
			key:"userinfo",
			success:function(res){
				wx.request({
					url:$.AdminUrl+"/YApi/getMySelfByLoginname",
					data:{loginname:res.data.loginname},
					success:function(res){
						$.userinfo = res.data.obj
						wx.setStorage({
							key: "userinfo",
							data: res.data.obj
						})
						that.setData({
							userinfo:res.data.obj
						})
					}
				})
			},fail:function(){
				wx.switchTab({
					url:"/pages/my/my"
				})
			}
		})
		wx.request({
				url:$.AdminUrl+"/YApi/getShopById",
				data:{shopid:$.myshopid},
				success:function(res){
					$.shopinfo = res.data.obj
					that.setData({
						shopinfo:res.data.obj
					})
				}
		})
	},
	onPullDownRefresh(){
		this.onLoad()
	},
	// 返回客户端
	gokehu:function(){
		wx.switchTab({
			url:"/pages/index/index"
		})
	},
	onShow: function() {

	},
	// 扫一扫
	scan() {
		wx.scanCode({
			success: (res) => {
				console.log(res)
				var ordernub = JSON.parse(res.result).ordernum
				wx.showLoading({title:"订单处理中..."})
				wx.request({
					url: $.AdminUrl + "/YApi/getOrderByOrdernum",
					data: {
						ordernum: ordernub
					},
					success: function(data) {
						wx.showLoading();
						var dataa = data.data.obj
						wx.navigateTo({
							url: '../order/orderxq/orderxq?id=' + dataa.id
						})
					}
				})
			}
		})
	},
	// 去订单页面
	goorder: function() {
		wx.redirectTo({
			url: "../order/order"
		})
	},
	// 去我的页面
	goindex: function() {
		wx.redirectTo({
			url: "../index/index"
		})
	},
})
